package com.credithc.customers.manager.schedule;

import com.credithc.customers.manager.service.ScheduleService;
import com.credithc.customers.manager.utils.StatsUtils;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.text.SimpleDateFormat;
import java.util.Date;

/***
 * @description: 历史数据统计初始化
 * @author: denghx
 * @date: 2019/4/18 11:52
 * @param: null
 * @return:
 */

@Slf4j
public class StatsManageInitJob implements Job {

    @Autowired
    private ScheduleService scheduleService;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        log.info("=========================================开始初始化统计当前时间前客户各系统标识数量=========================================");
        for (int i = 1; i < 200; i++) {
            String currentDay = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
            currentDay = StatsUtils.getPastDate(i, currentDay);
            scheduleService.statsManageStatistic(currentDay);
        }
    }
}
